#!/bin/bash
. config
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_dynaddr


#$ipt -t nat -A POSTROUTING -m state --state ESTABLISHED,RELATED -j ACCEPT
#$ipt -t nat -A POSTROUTING -o eth0 -j MASQUERADE


for prot in udp tcp
do
	for i in $(cat $basedir/forward.portas)
do
		$ipt -t nat -A POSTROUTING -p $prot --dport $i -j MASQUERADE
		$ipt -A FORWARD -i $iflan -p $prot --dport $i -j ACCEPT	
		$ipt -A FORWARD -o $iflan -p $prot --sport $i -j ACCEPT	
		
	done
	
done

#for prot in udp tcp
#do
#	for i in 20 21 40955
#do
#		$ipt -t nat -A POSTROUTING -p $prot --dport $i -m state --state NEW,RELATED,ESTABLISHED -j MASQUERADE
#		$ipt -A FORWARD -i $iflan -p $prot --dport $i -j ACCEPT	
#		$ipt -A FORWARD -o $iflan -p $prot --sport $i -j ACCEPT	
#		
#	done
#	
#done
